/*
 * @Description: 
 * @Author: ljy
 * @Date: 2021-11-28 16:17:31
 * @LastEditors: ljy
 * @LastEditTime: 2021-12-07 22:38:57
 */
var express = require('express');
var router = express.Router();
const mysql = require("mysql")


/* GET home page. */
router.get('/', function(req, res, next) {
    // res.render('index', { title: 'Express' });
    console.log(req.query.id);
    findAll(req.query.id, (result) => {
        res.send(result)
    })
});

/* GET home page. */
router.get('/deleteId', function(req, res, next) {
    // res.render('index', { title: 'Express' });
    console.log(req.query.id);
    // 1.创建连接对象
    let conn = mysql.createConnection({
        // 主机
        host: "localhost",
        // 数据库用户名
        user: "root",
        // 数据库密码
        password: "root2020",
        // 连接数据库名称
        database: "mydatabases"
    });
    // 2.发起连接
    conn.connect();
    // 3.执行sql语句，处理结果
    let sql = 'delete from t_comment where id =52 ';
    conn.query(sql, (error, result) => {
            if (error) throw error;
            console.log(result);
            res.send(result)
        })
        // 4.关闭连接
    conn.end();

});

module.exports = router;